/* 
    该文件专门为Count组件生成action对象
*/

import { INCREMENT, DECREMENT} from './constant.js'


// 所谓的异步action,就是action的值为一般对象Object
export const countIncrementAction = data=> (
    {type: INCREMENT,data}
)

export const countDecrementAction = data =>(
    {type: DECREMENT,data}
)

// 所谓的异步action,就是action的值为函数
// 异步actions中一般都会调用同步action
export const countIncrementAsyncAction = (data,time) =>{
    console.log(data);
    return (dispatch)=>{
        setTimeout(()=>{
            dispatch(countIncrementAction(data));
        },time)
    }
}